<?php
/**
 * Create By: PhpStorm
 * User: yihua
 * File: AddUserFeedback.php
 * Date: 2017/2/7
 * Time: 0:55
 */
namespace app\api\model\page\user;

use app\api\model\dao\UserFeedback;
use app\library\Error;
use think\Log;
use app\library\PageBase;

class AddUserFeedback extends PageBase
{
    private $objFeedback;

    public function __construct()
    {
        parent::__construct();
        $this->objFeedback = new UserFeedback();
    }

    public function excute($param)
    {
        $ret = $this->checkToken($param);
        if (false === $ret) {
            //return $this->getRes(Error::ERR_NO_AUTH);
        }
        if (!isset($param['user_id']) || !isset($param['content'])) {
            Log::alert('param error: ' . json_encode($param));
            return $this->getRes(Error::ERR_PARAM);
        }
        $pic = null;
        if (isset($param['picture'])) {
            //TODO:如果上传了图片，调用上传图片方法
            $pic = $param['picture'];
        }
        $this->objFeedback->addFeedback($param['user_id'], $param['content'], $pic);
        return $this->getRes();
    }

    public function uploadFeedbackPicture($param)
    {

    }
}
